{extend name="iframe" /}

{block name="body"}
<style>
    .layui-form-select{
        z-index: 1000;
    }
</style>
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <form action="{:request()->url()}" method="post" class="xn_ajax2" data-type="open">
        <div class="layui-form-item">
            <label class="layui-form-label">行业类型</label>
            <div class="layui-input-inline">
                <select name="parent_typeid" lay-filter="parent_typeid">
                    <option value="0">选择类型</option>
                    {foreach name="parent_typelist" item="vo"}
                    <option value="{$vo.id}" {if condition="$data.parent_typeid eq $vo.id"}selected{/if} >{$vo.title}</option>
                    {/foreach}
                </select>
            </div>
            <div class="layui-input-inline">
                <select name="typeid" id="typeid">
                    <option value="0">选择类型</option>
                    {foreach name="typelist" item="vo"}
                    <option value="{$vo.id}" {if condition="$data.typeid eq $vo.id"}selected{/if} >{$vo.title}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" lay-verify="required" placeholder="" autocomplete="off" class="layui-input" value="{$data.title}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">关键词</label>
            <div class="layui-input-block">
                <input type="text" name="post[keywords]" placeholder="" autocomplete="off" class="layui-input" value="{$data.post.keywords}">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">简介</label>
            <div class="layui-input-block">
                <textarea name="post[description]" class="layui-textarea">{$data.post.description}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属项目</label>
            <div class="layui-input-block">
                <input type="text" name="project" placeholder="" autocomplete="off" class="layui-input" value="{$data.project}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">属性</label>
            <div class="layui-input-block">
                {foreach name="attrlist" item="vo"}
                <input type="checkbox" name="post[attr_ids][]" value="{$vo.id}" lay-skin="primary" title="{$vo.title}" {if condition="in_array($vo.id,$data.post.attr_ids)"}checked{/if}><div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>{$vo.title}</span><i class="layui-icon layui-icon-ok"></i></div>
                {/foreach}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">人群</label>
            <div class="layui-input-block">
                {foreach name="crowdlist" item="vo"}
                <input type="checkbox" name="post[crowd_ids][]" value="{$vo.id}" lay-skin="primary" title="{$vo.title}" {if condition="in_array($vo.id,$data.post.crowd_ids)"}checked{/if}><div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>{$vo.title}</span><i class="layui-icon layui-icon-ok"></i></div>
                {/foreach}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">投资金额</label>
            <div class="layui-input-block">
                {foreach name="amountlist" item="vo"}
                <input type="checkbox" name="post[amount_ids][]" value="{$vo.id}" lay-skin="primary" title="{$vo.title}" {if condition="in_array($vo.id,$data.post.amount_ids)"}checked{/if}><div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>{$vo.title}</span><i class="layui-icon layui-icon-ok"></i></div>
                {/foreach}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">选址</label>
            <div class="layui-input-block">
                {foreach name="regionlist" item="vo"}
                <input type="checkbox" name="post[region_ids][]" value="{$vo.id}" lay-skin="primary" title="{$vo.title}" {if condition="in_array($vo.id,$data.post.region_ids)"}checked{/if}><div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>{$vo.title}</span><i class="layui-icon layui-icon-ok"></i></div>
                {/foreach}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">经营</label>
            <div class="layui-input-block">
                {foreach name="operatelist" item="vo"}
                <input type="checkbox" name="post[operate_ids][]" value="{$vo.id}" lay-skin="primary" title="{$vo.title}" {if condition="in_array($vo.id,$data.post.operate_ids)"}checked{/if}><div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>{$vo.title}</span><i class="layui-icon layui-icon-ok"></i></div>
                {/foreach}
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <textarea name="post[content]" id="content">{$data.post.content}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" lay-submit class="layui-btn">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
{/block}

{block name="js"}
<!--编辑器-->
<script src="/static/admin/ueditor/ueditor.config.js"></script>
<script src="/static/admin/ueditor/ueditor.all.min.js"></script>
<script src="/static/admin/ueditor/lang/zh-cn/zh-cn.js"></script>
<script>
    UE.getEditor('content',{
        initialFrameWidth :660,// 设置编辑器宽度
        initialFrameHeight:400,// 设置编辑器高度
        scaleEnabled:true
    });

    var form = layui.form;
    form.on('select(parent_typeid)', function(res) { 
        $("#typeid").empty();
        if(res.value != 0){
            $.get("{:url('admin/DataType/getSonType')}?pid="+res.value,function(result){
                if(result.status){
                    $("#typeid").append(new Option('请选择',0));
                    $.each(result.data,function(index,item){
                        $("#typeid").append(new Option(item.title,item.id));
                    });
                    form.render("select");
                }
            });
        }else{
            $("#typeid").append(new Option('请选择',0));
            form.render("select");
        }
    })
</script>
{/block}

